package C;

import java.util.Arrays;
import java.util.Scanner;

public class C9My {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m = Integer.parseInt(sc.nextLine());

        int[] requirements = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        System.out.println(getResult(m,requirements));
    }


    public static long getResult(int m,int[] requirements) {
        Arrays.sort(requirements);
        int n = requirements.length;
        long min = requirements[0];
        long max = requirements[n-1]+requirements[n-2];
        long ans = max;


        while (min<max) {
            long mid = (min+max)>>1;
            if (check(mid,m,requirements)) {
                ans = mid;
                max = mid-1;
            } else {
                min = mid+1;
            }
        }

        return ans;


    }

    public static boolean check(long mid,int m,int[] requirements) {
        int need = 0;
        int n = requirements.length;
        int left = 0,right = n-1;
        while (left<=right) {
            if (requirements[left]+requirements[right]>mid) {
                need++;
                right--;
            } else {
                need++;
                left++;right--;
            }
        }
        return need <= m;
    }
}
